home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / enterctl / readme.txt < prev   
Text File  |  1996-04-08  |  2KB  |  45 lines

  1.  
  2. Using the <Enter> key like a <Tab> key with Delphi Controls
  3. ===========================================================
  4.  
  5. The example code supplied here demonstrates how to trap the 
  6. <Enter> key and the cursor keys to provide better data entry
  7. processing.
  8.  
  9. The trick is to overide the Keypress and KeyDown events so
  10. that they process the keys the way you want. In the examples
  11. supplied I have used the <Enter> key to move to the next 
  12. control (like the <Tab> key) and the cursor Up and Down keys
  13. to move to the previous and next controls respectively.
  14.  
  15. The Edit and EBEdit use the cursor keys as stated above, but
  16. the Combobox and the Listbox use Shift-Up and Shift-Down 
  17. instead so as not to interfere with existing functionality.
  18.  
  19. The Grid control uses the <Enter> key to move between fields,
  20. however it will not move from the last field of the last row.
  21. It is very easy to make it exit the grid at this point if you
  22. need to.
  23.  
  24. The method used to move to the next/previous control is the 
  25. Windows API call SendMessage which is used to dispatch a 
  26. WM_NEXTDLGCTL to the form the controls are children to. 
  27. Delphi provides a function called GetParentForm to get the 
  28. handle of the parent form of the control.
  29.  
  30. These simple extensions can be expanded to respond to almost
  31. any keyboard event, and I think using this method is less 
  32. trouble than trapping keys in the forms OnKey events (using
  33. keypreview:=true).
  34.  
  35. Feel free to use the code as you wish, but if you discover 
  36. something new please let me in on it!
  37.  
  38.  
  39. Simon Callcott
  40.  
  41. CIS: 100574,1034
  42.  
  43.  
  44.  
  45.